package com.ecoolex.ying.space.api.graphql;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.modularize.api.service.storage.StorageInfo;
import com.ecoolex.framework.modularize.api.service.storage.StorageService;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.Source;
import com.ecoolex.framework.web.api.graphql2.annotation.TypeField;
import com.ecoolex.ying.space.entity.EstateProjectActivityBrand;
import com.ecoolex.ying.space.ws.EstateProjectActivityBrandService;

@GraphQL2Module(type = GraphQL2Module.Type.User,description = "地产项目合作品牌")
public class EstateProjectActivityBrandGraphql {

	@Reference
	private EstateProjectActivityBrandService service;
	
	@Autowired
    private StorageService storageService;
	
	@TypeField(type =  EstateProjectActivityBrand.class, field = "logo", description = "地产项目合作品牌Logo")
    public StorageInfo logo(@Source  EstateProjectActivityBrand source) {
        return storageService.get(source.getLogo());
    }
	
	@QueryField(field = "estateProjectActivityBrand" , description = "地产项目合作品牌")
	public EstateProjectActivityBrand get(@NonNull Integer brandId) {
		return service.get(brandId);
	}
	
	@QueryField(field = "estateProjectActivityBrandList" , description = "地产项目合作品牌列表")
	public Pagination<EstateProjectActivityBrand> query(@NonNull Integer projectId,@NonNull Page page) {
		return service.queryForH5(projectId,page);
	}
}
